import React, { Component } from 'react';
import { connect } from 'dva';
import { Button, InputItem, Toast } from 'antd-mobile';
import { Form, Modal } from 'antd';
import Login from '@/components/Login';
import styles from './Login.less';
import {
  removeAuthorization,
  saveAuthorization,
  saveMenus,
  saveOrg,
  saveRoles,
  saveUser,
} from '@/utils/bwdautil';
import { decode } from '@/utils/AesUtil';
import qs from 'qs';
import { addCookie } from '@/utils/utils';

const FormItem = Form.Item;
const { Tab, UserName, Password, Mobile, Captcha, Submit, ImageVerifyCode } = Login;

@connect(({ login, loading }) => ({
  login,
}))
class AhydTempLogin extends Component {
  state = {
    type: 'account',
    autoLogin: false,
    verifyCodeUuid: '',
    imageBase64: '',
    isNeedImageCode: false,
    verionData: {},
    pwdInutType: 'text',
  };

  handleSubmit = values => {
    const { dispatch } = this.props;


    dispatch({
      type: 'login/ahydTempLogin',
      payload: values,
      callback: (res) => {
        if (res.result == "fail") {
          Modal.error({title: '跳转失败', content: res.msg});
        }
      },
    });
  };

  async componentDidMount() {
    removeAuthorization();
    let token = decodeURIComponent(this.props.location.query.token);
    let appAcctId = decodeURIComponent(this.props.location.query.appAcctId);
    console.error("token:" + token);
    console.error("appAcctId:" + appAcctId);
    this.setState({ token: token }, () => {
    });
    // const t1 = "285303";
    // const t2 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJSRVMiLCJTRVJWSUNFSUQiOiJBSE1HU0oiLCJpc3MiOiJRSERYIiwiZXhwIjoxNjA3MjQ1NDc2LCJpYXQiOjE2MDcwNjU0NzYsIkxPR0lOQUNDVCI6ImFoeWQifQ.N-PnvAeKtK9fzajRfPdVBDWSN1MvYYdH9IJ9SdJcF40.53EF5D6E635F9C4E";

    let params = {
      token:token,
      appAcctId: appAcctId,
    };
    this.handleSubmit(params);
  }

  outfiles;
  render() {
    const { login, submitting } = this.props;
    const { type, imageBase64, isNeedImageCode, verionData, pwdInutType } = this.state;
    return <div className={styles.main}></div>;
  }
}

export default AhydTempLogin;
